package cn.wen.yinxiu.member.server.codec;import cn.wen.yinxiu.common.toolkit.SerializationUtil;import cn.wen.yinxiu.member.server.protocol.Packet;import io.netty.buffer.ByteBuf;import io.netty.channel.ChannelHandlerContext;import io.netty.handler.codec.MessageToByteEncoder;/** * @ClassName: ObjEncoder * @Author: 小飞 * @Date: 2023/5/28 14:26 * @Description: 编码器 */public class ObjEncoder extends MessageToByteEncoder<Packet> {    @Override    protected void encode(ChannelHandlerContext ctx, Packet in, ByteBuf out) {        // 1.序列化  TODO 可以使用SPI来实现序列化机制        byte[] data = SerializationUtil.serialize(in);        out.writeInt(data.length + 1);        out.writeByte(in.getCommand()); //添加指令        out.writeBytes(data);    }}